package org.nf.web.view;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletResponse;
import org.nf.web.servlet.ServletApi;
import org.nf.web.servlet.View;

import java.io.IOException;

/**
 * @author zhu
 * @date 2024-05-20
 */
public class RedirectView implements View {
    /**
     * 重定向的地址
     */
    private final String url;

    public RedirectView(String url) {
        this.url = url;
    }

    @Override
    public void render(ServletApi servletApi) throws ServletException, IOException {
        HttpServletResponse resp = servletApi.resp();
        resp.sendRedirect(url);
    }
}
